{
 Pashkvich_Ivan
 19.09.2012
 You know what I mean
}
program minmax;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, j, s: integer;
  fin: textfile;
  a: array of integer;

begin
  assignfile(fin, 'input.txt');
  reset(fin);
  readln(fin, n);
  setlength(a, n);
  for i:=1 to n do
  begin
    read(fin, a[i]);
  end;
  for j:= 1 to n do
  begin
    for i:=0 to n-j do
    begin
      if (a[i]>a[i+1]) then
      begin
        s:=a[i];
        a[i]:=a[i+1];
        a[i+1]:=s;
      end;
    end;
  end;
  writeln(a[1]+a[n]);
  readln;
  closefile(fin);
end.
 